<?php

class commentEvent extends Model
{

	function getComment($id)
	{
		$gcomment = $this->db->getAll("SELECT event.name,
				ce.comment_id,
				ce.date,
				ce.comment,
				organization.name Org,
				user.lastname, 
				user.firstname,
				user.middlename
			FROM event,organization, commentevent ce, user
			WHERE event.org_id = organization.org_id 
			AND ce.stud_no = user.stud_no
			AND ce.event_id = event.event_id
			AND event.event_id = ?
			ORDER BY ce.date ASC",
			array($id)
		);
		return $gcomment;
	}

	function insertComment ( $event_id, $stud_no, $date, $comment )
	{
		$icomment = $this->db->execute("INSERT INTO commentevent( event_id,
			stud_no,
			date,
			comment )
			VALUES ( ?, ?, ?, ? )", 
			array(  $event_id, $stud_no, $date, $comment )
		);
		return $icomment;
	}

	function updateComment(  $event_id, $stud_no, $date, $comment, $comment_id ) 
	{
		$ucomment = $this->db->execute("UPDATE commentevent
			SET event_id = ?,
			stud_no = ?,
			date = ?,
			comment = ?			
			WHERE comment_id = ?",
			array(  $event_id, $stud_no, $date, $comment, $comment_id  )
		);
		return $ucomment;
	}

	function deleteComment ( $comment_id )
	{
		$dcomment = $this->db->execute("DELETE FROM commentevent
			WHERE comment_id  = ? ",
			array( $comment_id  )
		);
	}
}